package com.level.restful.util.httpLogUtil;

import javax.servlet.http.HttpServletRequest;

/**
 * @author tqf
 *
 */
public class RequestThreadBinder {
    /**
     * 声明当前线程 指定泛型为request
     */
    private static ThreadLocal<HttpServletRequest> local = new ThreadLocal<HttpServletRequest>();

    /**
     * 将request绑定到当前线程的方法
     * @param request
     */
    private void setLocal(HttpServletRequest request){
        local.set(request);
    }

    /**
     * 从当前线程获取request的方法
     * @return
     */
    public static HttpServletRequest getRequest() {
        return local.get();
    }

    /**
     * 从当前线程移除request的方法
     */
    public static void removeRequest() {
        local.remove();
    }


}
